package com.itheima.test;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Random;
import java.lang.Math;

public class MyJFrame2 extends JFrame implements MouseListener {
    JButton jbtn1 = new JButton("btn1");
    JButton jbtn2 = new JButton("btn2");

    public MyJFrame2(){
        this.setSize(603, 680);
        //设置界面标题
        this.setTitle("拼图单机版 V1.0");
        //设置窗口置顶
        this.setAlwaysOnTop(true);
        this.setLocationRelativeTo(null);
        //设置默认关闭模式
        this.setDefaultCloseOperation(3);
        //取消默认的居中对齐的布局方式
        this.setLayout(null);

        jbtn1.setBounds(0, 0, 100, 50);
        jbtn1.addMouseListener(this);
        this.add(jbtn1);
        this.add(jbtn2);

        this.setVisible(true);

    }

    @Override
    public void mouseClicked(MouseEvent e) {
        System.out.println("click");
    }

    @Override
    public void mousePressed(MouseEvent e) {
        System.out.println("press");
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        System.out.println("mouseup");
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        System.out.println("enter...");
    }

    @Override
    public void mouseExited(MouseEvent e) {
        System.out.println("leave...");
    }
}
